typedef struct {
    int key;
    int val;
    UT_hash_handle hh;
} HashTable;

HashTable* hashTable;

static HashTable* get(int key)
{
    HashTable* tmp;
    HASH_FIND_INT(hashTable, &key, tmp);
    return tmp;
}

static void put(int key, int val) {
    HashTable* tmp = get(key);
    if (tmp == NULL) {
        tmp = malloc(sizeof(HashTable));
        tmp->key = key;
        tmp->val = val;
        HASH_ADD_INT(hashTable, key, tmp);
    }
    else {
        tmp->val = val;
    }
}

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* twoSum(int* nums, int numsSize, int target, int* returnSize) {
    hashTable = NULL;
    for (int i = 0; i < numsSize; ++i) {
        HashTable* tmp = get(target - nums[i]);
        if (tmp == NULL) {
            put(nums[i], i);
        }
        else {
            int* res = malloc(sizeof(int) * 2);
            res[0] = tmp->val;
            res[1] = i;
            *returnSize = 2;
            return res;
        }
    }

    *returnSize = 0;
    return NULL;
}